package com.bite.SingletonModel.LazyModel;

public class SingletonModelLazy {
    //定义一个全局变量
    private static SingletonModelLazy instance = null;
    //构造方法私有化
    private SingletonModelLazy() {};
    //获取类对象
    public static SingletonModelLazy getInstance() {
        //判断是否要加锁
        if (instance == null) {
            //获取锁
            synchronized (SingletonModelLazy.class) {
                //判断对象是否创建过
              if (instance == null) {
                  //修改
                  instance = new SingletonModelLazy();
              }
            }
        }
        return instance;
    }

}
